package homework;

public class zy08 {
	public static void main(String[] args) {
		System.out.println(findlongest("asddsa"));
		
	}
	public static int findlongest(String str){
		StringBuffer str1=new StringBuffer();
		int maxLength = 0;
		for(int i=0;i<str.length();i++){
			char find = str.charAt(i);
			String findstr = "" + find;
			int index=str1.indexOf(findstr);
			if(index!=-1){
				str1 = new StringBuffer(str1.substring(index + 1));
			}
			str1.append(find);
			maxLength = Math.max(maxLength, str1.length());
		}
		return maxLength;
	}
}
